#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5;
ll read(){
    ll x=0,f=1;char c=getchar();
    for(;!isdigit(c);c = getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c = getchar()) x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
ll n,m,L,V,ans1,ans2;

struct node{
    ll dd,vv,aa;
}car[N + 5];

ll p[N + 5],p1[N + 5];
bool is[N + 5],h[N];
vector<ll> ch[N];

void solve(node* car, ll *p)
{
    ans1 = 0,ans2 = m;
    bool f = 1;
    ll cnt = 0,cnt1 = 0;
    for(ll i = 1 ; i <= n ; i++)
    {
        ll d = car[i].dd;
        f = 1;
        cnt1 = 0;

        while(car[i].vv > 0 && d <= L && cnt1 <= m)
        {
            cnt1++;
            ll v0 = car[i].vv;
            ll* s = upper_bound(p + 1, p + m + 1, d);
            if(*s <= 0 || *s > L) break;
            if(p[s - p- 1] == d)
            {
                if(v0 > V && f){
                    ans1++;
                    f = 0;
                    p1[s - p - 1]++;
                    if(is[s - p - 1] != 1) is[s - p - 1] = 1,cnt++, ch[s- p - 1].push_back(i);
                }
            }
            if(v0 * v0 + 2 * car[i].aa * (*s - car[i].dd) > V * V){
                if(f)ans1++,f = 0;
                p1[s - p]++;
                if(is[s  - p] != 1) is[s - p] = 1 , cnt++ , ch[s - p].push_back(i);
            }
            d = *s;
            if(v0 * v0 + 2 * car[i].aa * (*s - car[i].dd) <= 0) break;
        }
    }
    bool ok = 1;
    if(ch[p[1]].size() == 0) ans2--;
    for(ll i = 2 ; i <= m ; i++)
    {
        memset(h,0,sizeof(h));
        ok = 1;
        for(ll j = 0;j < ch[p[1]].size();j++)
        {
            h[ ch[ p[1] ][ j ] ] = 1;
        }
        for(ll j = 0; j <ch[p[i]].size();j++)
        {
            ll k = 0;
            if(h[ ch[ p[i] ][ j ] ] == 0){
            if(ok) ok = 0;
            ch[ p[1] ].push_back(ch[p[i]][j]);
            k++;
            }
            if(ok == 1) ans2--;
        }
    }
    printf("%lld %lld\n",ans1,ans2);
    return;
}

int main(){
   freopen("detect.in","r",stdin);
   freopen("detect.out","w",stdout);
    ll T = read();
    for(ll i = 0 ; i < T ;i ++)
    {
        n = read(),m = read() , L = read() , V = read();
        memset(car,0,sizeof(car));
        memset(p , 0 , sizeof(p));
        memset(is, 0 ,sizeof(is));
        for(ll j = 1; j <= n ; j ++)
        {
            car[j].dd = read(),car[j].vv = read(),car[j].aa = read();
        }
        for(ll j = 1 ; j <= m ; j++)
            p[j] = read();
        solve(car,p);
    }
    return 0;
}
